package com.baikeyang.app.controller.admin.toilet;

import com.baikeyang.common.bean.ResponseResult;
import com.baikeyang.common.util.StringUtils;
import com.baikeyang.service.toilet.IToiletInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

/**
 * 公共厕所管理Controller
 * Created by lenovo on 2019/4/26.
 */
@RestController(value = "toiletController")
@RequestMapping(value = "/admin/toilet")
public class ToiletController {

    @Autowired
    private IToiletInfoService toiletService;

    @RequestMapping(value = "index", method = RequestMethod.GET)
    public ModelAndView index () {
        return new ModelAndView("/admin/toilet/toilet-index");
    }

    @RequestMapping(value = "map", method = RequestMethod.GET)
    public ModelAndView map () {
        return new ModelAndView("/admin/toilet/toilet-map");
    }

    @RequestMapping(value = "all", method = RequestMethod.GET)
    public ResponseResult list () {
        return toiletService.getToilets();
    }

    @RequestMapping(value = "list", method = RequestMethod.POST)
    public ResponseResult list (String areaType, String areaCode) {
        return toiletService.getToiletsByAreaCode(areaType, areaCode);
    }

    @RequestMapping(value = "search", method = RequestMethod.POST)
    public ResponseResult search(String lng, String lat, String radius) {
        return toiletService.getToiletsByLnglat(lng, lat, radius);
    }

}
